﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp9
{

    class Program
    {       
        static void Main(string[] args)
        {
            try
            {
                while (true)
                {

                    Console.WriteLine("请选择：1.输入成绩 2.查询结果");
                    int key = int.Parse(Console.ReadLine());
                    switch (key)
                    {
                        case 1:
                            Console.WriteLine("请输入您的考试成绩：");
                            double b = double.Parse(Console.ReadLine());
                            Console.WriteLine(a);
                            arrayList.Add(a);
                            a += b;
                            break;
                        case 2:
                            Console.WriteLine(a / arrayList.Count);
                            Console.WriteLine(a);
                            Console.WriteLine(arrayList.Count);
                            break;
                        default:
                            break;
                    }
                }
            }
            catch (FormatException )
            {

                Console.WriteLine("异常已处理！");

            }
            catch (OverflowException )
            {
                Console.WriteLine("异常已处理！");
            }

            catch (Exception )
            {
                Console.WriteLine("异常已处理！");
            }
            finally
            {
                Console.WriteLine("最后异常处理成功！");
            }
        }
        static double a = 0;
        static ArrayList arrayList = new ArrayList();
    }
}